#include "aes_demo.h"

extern unsigned char AES_Key_Table[32];

extern void aesEncInit(void);
extern void aesEncrypt(unsigned char *dat,unsigned char *buff);
extern void aesDecInit(void);
extern void aesDecrypt(unsigned char *dat,unsigned char *buff);

static unsigned char chainCipherBlock[16];

void AES_SetKey(unsigned char *buff)
{
  for(unsigned char i=0;i<32;i++) AES_Key_Table[i]=buff[i];
}

void AES_EncryptInit(void)
{
  for(unsigned char i=0;i<sizeof(chainCipherBlock);i++) {
    chainCipherBlock[i] = 0;
  }
  aesEncInit();
}

void AES_Encrypt(unsigned char *dat)
{
  aesEncrypt(dat, chainCipherBlock);
}

void AES_DecryptInit(void)
{
  for(unsigned char i=0;i<sizeof(chainCipherBlock);i++) {
    chainCipherBlock[i] = 0;
  }
  aesDecInit();
}

void AES_Decrypt(unsigned char *dat)
{
  aesDecrypt(dat, chainCipherBlock);
}
